home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / dev / misc / IOBlixDevKitR2.lha / IOBlixDevKit / C / examples / QueryChipList.c < prev    next >
C/C++ Source or Header  |  1999-01-18  |  2KB  |  52 lines

  1. /*
  2.     This program is meant to demonstrate how to get all necessary information
  3.     about all available chips on an IOBlix board in a system-friendly manner
  4. */
  5.  
  6. #include <exec/exec.h>
  7. #include <resources/ioblix.h>
  8. #include <stdio.h>
  9. #include <string.h>
  10.  
  11. #include <proto/exec.h>
  12. #include <proto/ioblix.h>
  13.  
  14.  
  15. UBYTE __aligned myname[]="QueryChipList 37.1 "__AMIGADATE__;
  16. UBYTE __aligned version[]="$VER: QueryChipList 37.1 "__AMIGADATE__;
  17. UBYTE __aligned copyright[]="(C)opyright 1998,1999 by Thore Böckelmann and RBM Computertechnik. All rights reserved";
  18.  
  19. struct IOBlixResource *IOBlixBase = NULL;
  20.  
  21. void main(void)
  22. {
  23.     struct List *chipList;
  24.     struct IOBlixChipNode *chipNode;
  25.     ULONG uartCnt, ppCnt, fifoCnt, otherCnt;
  26.  
  27.     IOBlixBase = (struct IOBlixResource *)OpenResource(IOBLIXRESNAME);
  28.     if (IOBlixBase) {
  29.         /* try to get a copy of the global chip list */
  30.         chipList = AllocChipList();
  31.         if (chipList) {
  32.             uartCnt = ppCnt = fifoCnt = otherCnt = 0;
  33.             /* let's count all the available chips in the system */
  34.             for (chipNode = (struct IOBlixChipNode *)chipList->lh_Head; chipNode->icn_Node.ln_Succ; chipNode = (struct IOBlixChipNode *)chipNode->icn_Node.ln_Succ) {
  35.                 switch (chipNode->icn_Type) {
  36.                     case ICT_SERIAL_Z2_CHIP: uartCnt++; break;
  37.                     case ICT_PARALLEL_Z2_CHIP: ppCnt++; break;
  38.                     case ICT_EXTFIFO_Z2_CHIP: fifoCnt++; break;
  39.                     default: otherCnt++; break;
  40.                 }
  41.             }
  42.             printf("There are %ld UARTs, %ld parallel ports, %ld external FIFOs and %ld other chips in your system.\n", uartCnt, ppCnt, fifoCnt, otherCnt);
  43.             FreeChipList(chipList);
  44.         } else {
  45.             printf("Can't get a copy of the chip list!\n");
  46.         }
  47.     } else {
  48.         printf("Can't find ioblix.resource. Please run SetupIOBlix\n");
  49.     }
  50. }
  51.  
  52.